package 力扣日常刷题.木22二月.第21天227;

/**
 * @author 帅小伙
 * @date 2022/2/27
 * @description
 */
public class Demo172 {

    public static void main(String[] args) {
        minimumTime(new int[]{1,2,3},5);
    }

    public static  long minimumTime(int[] time, int totalTrips) {
        long  l = 1,r = Long.MAX_VALUE;

        while(l < r) {
            long mid = (r-l) / 2 + l;
            long count = 0;
            for (int i : time) {
                if(count >= totalTrips) break;
                count %= Long.MAX_VALUE;
                count += (mid/i) % Long.MAX_VALUE;
            }
            if(count >= totalTrips) r = mid;
            else l = mid + 1;
        }
        return l;
    }
}
